package com.cardbaobao.cardbabyclient.ui.adapter;

import android.content.Context;
import android.view.View;
import android.widget.ImageView;

import com.cardbaobao.cardbabyclient.R;
import com.cardbaobao.cardbabyclient.model.UserBindCards;
import com.cardbaobao.cardbabyclient.ui.adapter.base.CommonAdapter;
import com.cardbaobao.cardbabyclient.ui.adapter.base.ViewHolder;
import com.cardbaobao.cardbabyclient.utils.ImageLoaderUtil;
import com.cardbaobao.cardbabyclient.utils.URLUtil;

import java.util.List;

/**
 * Created by FHW
 * on 2017/11/08 19:13.
 */

public class ChooseRepaymentWayAdapter extends CommonAdapter<UserBindCards.DebitCard> {

    public ChooseRepaymentWayAdapter(Context mContext, List<UserBindCards.DebitCard> mData) {
        super(mContext, mData, R.layout.item_choose_repyament_way);
    }

    @Override
    public void convert(ViewHolder holder, UserBindCards.DebitCard item, int position) {
        if (position == (getCount() - 1)) {
            holder.getView(R.id.iv_arrow).setVisibility(View.VISIBLE);
            holder.setText(R.id.tv_credit_card, "更换银行卡");
            holder.getView(R.id.iv_icon).setBackgroundResource(R.mipmap.icon_card);
            holder.getView(R.id.iv_arrow).setBackgroundResource(R.mipmap.icon_adjunction_right);
        } else {

            ImageLoaderUtil.displayImageWithPlaceHolder(URLUtil.CBB_IMG_URL + item.getPicture(), (ImageView) holder.getView(R.id.iv_icon), R.mipmap.img_default_square);
            String str = item.getDebit_card_no();
            holder.setText(R.id.tv_credit_card, item.getDebit_card_name() + "储蓄卡（" + str.substring(str.length() - 4, str.length()) + "）");

            if (item.isChoose()) {
                holder.getView(R.id.iv_arrow).setVisibility(View.VISIBLE);
            } else {
                holder.getView(R.id.iv_arrow).setVisibility(View.GONE);
            }
        }

    }

}
